package com.bdqn.service.impl;

import com.bdqn.mapper.DeptMapper;
import com.bdqn.pojo.Dept;
import com.bdqn.service.DeptService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DeptServiceImpl implements DeptService {
    @Autowired
    DeptMapper deptMapper;
    @Override
    public PageInfo<Dept> selectPage(int pageNum, int pageSize, String name) {
        //开始分页,设置当前页的页号和每页显示的条数
        PageHelper.startPage(pageNum,pageSize);
        //获取所有信息
        List<Dept> list=deptMapper.selectByName(name);
        //获取当前页的信息对象
        PageInfo<Dept> pageInfo=new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public int addDept(Dept dept) {
        return deptMapper.add(dept);
    }

    @Override
    public int updateDept(Dept dept) {
        return deptMapper.update(dept);
    }

    @Override
    public int deleteDept(int id) {
        return deptMapper.delete(id);
    }

    @Override
    public int updateStatus(int deptId, String status) {
        return deptMapper.updateStatus(deptId,status);
    }
}
